import request from '@/config/axios'

export interface InvestigateVO {
  id: number
  title: string
  description: string
  beginDate: Date
  endDate: Date
  sort: number
  investigateMode: number
  joinNum: number
  investigateInterval: number
  enabled: Boolean
  userId: number
}
export interface InvestigateItemOpinionVO {
  id: number
  itemAnswer: string
}
// 查询问卷调查列表
export const getInvestigatePage = async (params) => {
  return await request.get({ url: '/cms/investigate/page', params })
}

// 查询问卷调查详情
export const getInvestigate = async (id: number) => {
  return await request.get({ url: '/cms/investigate/get?id=' + id })
}

// 新增问卷调查
export const createInvestigate = async (data: InvestigateVO) => {
  return await request.post({ url: '/cms/investigate/create', data })
}

// 修改问卷调查
export const updateInvestigate = async (data: InvestigateVO) => {
  return await request.put({ url: '/cms/investigate/update', data })
}

// 删除问卷调查
export const deleteInvestigate = async (id: number) => {
  return await request.delete({ url: '/cms/investigate/delete?id=' + id })
}

// 导出问卷调查 Excel
export const exportInvestigateApi = async (params) => {
  return await request.download({ url: '/cms/investigate/export-excel', params })
}

// 查询问卷调查题目反馈意见列表
export const getInvestigateItemOpinonPage = async (params) => {
  return await request.get({ url: '/cms/investigate-item-op/page', params })
}

// 修改问卷调查条目意见
export const updateInvestigateItemOpinion = async (data: InvestigateItemOpinionVO) => {
  return await request.put({ url: '/cms/investigate-item-op/update', data })
}

// 删除问卷调查条目意见
export const deleteInvestigateItemOpinion = async (id: number) => {
  return await request.delete({ url: '/cms/investigate-item-op/delete?id=' + id })
}
